package viewpagerindicator;

import com.example.costs.MainActivity;
import com.example.costs.R;
import com.example.costs.TrListViewArrayAdapter;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import java.util.ArrayList;

import base.DB;
import base.Transaction;

public final class TestFragment extends Fragment{
    private static final String KEY_CONTENT = "TestFragment:Content";
    private static FragmentActivity fragmentActivity;

    public static TestFragment newInstance(String content) {
        TestFragment fragment = new TestFragment();
        fragment.mContent = content;
        Log.d("newInstance", "newInstance");
        return fragment;
    }

    private String mContent = "???";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) {
            mContent = savedInstanceState.getString(KEY_CONTENT);
        }
        Log.d("onCreate", "onCreate");
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view=null;
        if(mContent.equalsIgnoreCase("income_layout"))
        {
            view = inflater.inflate(R.layout.income_layout, container, false);

        }
        else if(mContent.equalsIgnoreCase("outcome_layout"))
        {
            view = inflater.inflate(R.layout.outcome_layout, container, false);
        }
        Log.d("onCreateView", "onCreateView");
        return view;
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        Log.d("onSaveInstanceState", "onSaveInstanceState");
        outState.putString(KEY_CONTENT, mContent);
    }


//        ArrayAdapter<String> adapterTr = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1, MainActivity.db.fetchAllTr(MainActivity.user.getuId(),MainActivity.trType));
//        setListAdapter(adapterTr);


    @Override
    public void onStart() {
        super.onStart();
        Transaction.getAllTr(MainActivity.viewPager,MainActivity.mainActivity.getLayoutInflater(),"e");
        Log.d("onStart", "onStart");
    }

    @Override
    public void onResume() {
        super.onResume();
        Log.d("onResume", "onResume");
    }

}
